//2009/08/13 18:26:45
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class Medici
{
public:
    int winner(vector <int> fame, vector <int> fortune, vector <int> secrets)
    {
		int ret = -1;
		int mmax = -1;
		bool ties = false;
		for(int i=0; i<fame.size(); i++)
		{
			int mmin = min(fame[i], min(fortune[i], secrets[i]));
			if(mmin > mmax) 
			{
				mmax = mmin;
				ties = false;
				ret = i;
			}
			else if(mmin == mmax) ties = true;
		}
		if(ties) ret = -1;
		return ret;
    }
};
